﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WpfApplicationExperimental
{


    /// <summary>
    /// Interaction logic for ColumnSelectionWindow.xaml
    /// </summary>
    public partial class ColumnSelectionWindow : Window
    {

        public List<string> columnsSelected = new List<string>();
        IList<CheckBox> boxes;
        public void CreateColumns(Type type)
        {
           List < System.Reflection.PropertyInfo> propertiesInfos =  type.GetProperties().ToList ();

          boxes = new List<CheckBox>();
           
            foreach (System.Reflection.PropertyInfo info in propertiesInfos)
            {
                DockPanel  box = new DockPanel () ; box.Name = info.Name;
                Label id_l = new Label(); id_l.Content = info.Name;
                CheckBox id_c = new CheckBox(); id_c.Name = info.Name;
                box.Children.Add(id_l); box.Children.Add(id_c);
                boxes.Add(id_c );
                this.stackPanel1.Children.Add(box); 
            }


            Button ok = new Button(); ok.Content = "Ok"; ok.Click += new RoutedEventHandler(ok_Click);
            Button calcel = new Button(); calcel.Content = "Cancel"; calcel.Click += new RoutedEventHandler(calcel_Click);
            this.stackPanel1.Children.Add(ok); this.stackPanel1.Children.Add(calcel);


        }

        void calcel_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        void ok_Click(object sender, RoutedEventArgs e)
        {
            foreach (CheckBox box in boxes)
                if (box.IsChecked == true )
                    columnsSelected.Add(box.Name);

            this.Close();
        }

        public ColumnSelectionWindow()
        {
            InitializeComponent();
           // CreateColumns(typeof (DataAccesLayer .Document ));
        }
    }
}
